package com.baicaoyuan.web.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

@RequiredArgsConstructor
@Getter
public enum BusinessTypeEnum {

    /**
     * buy
     */
    BUY("1"),

    /**
     * sale
     */
    SALE("2");


    private final String status;

    /**
     * 根据标识获取枚举
     *
     * @param businessStatus
     * @return
     */
    public static BusinessTypeEnum acquire(final String businessStatus) {
        Optional<BusinessTypeEnum> belongEnum = Arrays.stream(BusinessTypeEnum.values())
                .filter(v -> Objects.equals(v.getStatus(), businessStatus))
                .findFirst();
        return belongEnum.orElse(BusinessTypeEnum.BUY);
    }

}
